home *** CD-ROM | disk | FTP | other *** search
/ QuickTime for the Web (2nd Edition) / QuickTime for the Web (2nd Edition).iso / pc / Demos / Mac / Matthew's Behaviors / DayOfWeekƒ / DayOfWeek next >
Encoding:
INI File  |  2001-09-10  |  3.0 KB  |  95 lines

  1. [Name]
  2. DayOfWeek v1.0 - Provides properties for day of week.
  3. By Matthew Peterson, matthew@pinoko.berkeley.edu
  4.  
  5. [Description]
  6. 2-19-2000
  7. This behavior has one custom event used to update two Global Variables:
  8.  
  9. UpDateWeekDay: Updates the following two Global Variables:
  10.          1)  LocalWeekDay:  the day of the week (Sunday thru Saturday) 
  11.                                                                                                 in the local time zone
  12.  
  13.          2)   GMTWeekDay:  the day of the week (Sunday thru Saturday) 
  14.                                                                                                 in the GMT time zone
  15.  
  16. 1 = Sunday, 2 = Monday.... 7 = Saturday
  17. (a value of 0 means the variable hasn't been evaluated yet. This
  18. can happen if you have something)
  19.  
  20. To use this behavior, simply place it on a sprite, and execute the UpDateWeekDay
  21. event (only needs to be called once during the course of the movie).
  22. The above global variables will be made available to all sprites in the sprite track.
  23.  
  24. Currently Quicktime offers properties for local and GMT date and time
  25. but lacks a property to know what day of the week it is. This is often
  26. useful for wired movies that want to show something different on 
  27. one day, than what is shown during the rest of the week.
  28.  
  29. EXAMPLE: (Set the image index of sprite 2 to 19 if today is Monday)
  30.  
  31. GlobalVars localweekday GMTweekday
  32.  
  33. spriteofid(1).executeevent($UpdateWeekDay) //really only needs to be called once in the movie.
  34. //This assumes that this behavior is in spriteofid(1).
  35. IF(localweekday = 2) //today is monday
  36.     SpriteOfID(2).SetImageIndexTo(19)
  37. ENDIF
  38.  
  39. Revision History:
  40. 3-2-2000 -- Added missing lines that caused the wrong day after the leap year.
  41.  
  42. [Parameters]
  43.  
  44. [200008 UpdateWeekDay]
  45. GlobalVars localweekday GMTweekday MP_thismonth MP_thisyear MP_thisday MP_Tempmonthtoadd[12] MP_janstart
  46. //Calculates what day of the week it is. 1 = Sunday 2 = Monday... and 7 = Saturday
  47. //Returns two variable localweekday and GMTweekday.
  48. //If these values = 0 then this function hasn't been executed yet.
  49. //By Matthew Peterson.
  50.  
  51.  
  52.     MP_Tempmonthtoadd[0]=0
  53.     MP_Tempmonthtoadd[1]=3
  54.     MP_Tempmonthtoadd[2]=3
  55.     MP_Tempmonthtoadd[3]=6
  56.     MP_Tempmonthtoadd[4]=1
  57.     MP_Tempmonthtoadd[5]=4
  58.     MP_Tempmonthtoadd[6]=6
  59.     MP_Tempmonthtoadd[7]=2
  60.     MP_Tempmonthtoadd[8]=5
  61.     MP_Tempmonthtoadd[9]=0
  62.     MP_Tempmonthtoadd[10]=3
  63.     MP_Tempmonthtoadd[11]=5
  64.  
  65. MP_thisday = LocalDay
  66. MP_thisyear = LocalYear - 2000
  67. MP_thismonth = LocalMonth
  68.  
  69. IF(MP_thisyear = 0)
  70.     MP_janstart = 6
  71. ELSE
  72.     MP_janstart = 7 + MP_thisyear +  (MP_thisyear - 1) DIV 4
  73. ENDIF
  74. IF(MP_thismonth > 2)
  75.     MP_janstart = MP_janstart + ((MP_thisyear REM 4) = 0)
  76. ENDIF
  77.  
  78. localweekday = ((MP_janstart + MP_Tempmonthtoadd[MP_thismonth - 1] + MP_thisday - 1) REM 7) + 1
  79.  
  80. //Calculate again for GMT because we might fall on the edge of a month, and it is just
  81. //as fast to recalculate as it is to account for possible month crossing.
  82. MP_thisday = GMTDay
  83. MP_thisyear = GMTYear - 2000
  84. MP_thismonth = GMTMonth
  85.  
  86. IF(MP_thisyear = 0)
  87.     MP_janstart = 6
  88. ELSE
  89.     MP_janstart = 7 + MP_thisyear +  (MP_thisyear - 1) DIV 4
  90. ENDIF
  91. IF(MP_thismonth > 2)
  92.     MP_janstart = MP_janstart + ((MP_thisyear REM 4) = 0)
  93. ENDIF
  94. GMTweekday = ((MP_janstart + MP_Tempmonthtoadd[MP_thismonth - 1]+MP_thisday - 1) REM 7) + 1
  95.